<template>
  <div class="item-container">
    <div
      class="item"
      v-for="item in data.list"
      :key="item.id"
      @click="$router.push({name: 'NewsDetails', params: { article_id:`${item.article.id}`}})"
    >
      <div class="left" >
        <b>{{ item.article.user.nickname }} </b>
        <span>| </span> <span>{{ item.article.createdAt | time }}</span> <span>| </span>
        <span>{{ item.article.category.name }}</span>
        <h2>{{ item.article.title }}</h2>
        <p class="item-content" v-text="item.article.content"></p>
        <ul>
          <li>
            <a><i class="el-icon-view"></i>&nbsp;{{ item.article.read_count }}</a>
          </li>
          <li>
            <a><i class="el-icon-thumb"></i>{{ item.article.like_count }}</a>
          </li>
          <li>
            <a><i class="el-icon-chat-round"></i>{{ item.article.comment_count }}</a>
          </li>
          <li>
            <a><i class="el-icon-more"></i></a>
          </li>
        </ul>
      </div>
      <div class="right">
        <el-image :src="item.article.cover_img" fit="contain"></el-image>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Item",
  props:{
    data: Object,
    required: true,
    default: function () {
        return {}
    }
  },
  data() {
    return {
     
    };
  },
};
</script>
<style lang="scss" scoped>
.item-container {
  // width: 851px;
  // min-width: 851px;
}
.item:hover {
  cursor: pointer;
  background: #fafafa;
  border-radius: 8px;
}
.item {
  display: flex;
  justify-content: space-between;
  padding: 15px 0 15px 0;
  border-bottom: 1px solid #dee0e2;
  // overflow: hidden; //隐藏文字
  //  background: #cac2c2;
  .left {
    width: 620px;
    // height: 100px;
    //  background: #9b5b5b;
    b {
      color: #66696d;
      font-size: 13px;
    }
    span {
      margin: 0px 1px;
    }
    span,
    p {
      color: #86909c;
      font-size: 13px;
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden; //隐藏文字
    }
    i {
      color: rgb(160, 150, 150);
      margin-right: 2px;
    }
    a {
      color: #4e5969;
    }
    h2 {
      white-space: nowrap;
      text-overflow: ellipsis;
      overflow: hidden; //隐藏文字
      font-size: 16px;
      color: #1d2129;
    }
    ul > li {
      list-style-type: none;
      // width: 35px;
      float: left;
      margin-right: 15px;
      font-size: 14px;
    }
  }
  .right {
    display: flex;
    flex-wrap: wrap;
    align-content: center;
    .el-image {
      border-radius: 4px;
      width: 150px;
      overflow: hidden;
    }
  }
}
</style>
